<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
    <meta http-equiv="Content-Type" content="text/html;charset=UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1.0">
    <title>资讯列表</title>
    <link rel="stylesheet" href="../assets/css/dropload.css"/>
    <style type="text/css">
        html, body {
            margin: 0;
            padding: 0;
            letter-spacing: 1px;
            background-color: #e7eaf3;
            font-family: Arial, 'Microsoft YaHei';
        }

        .header-section {
            color: #fff;
            height: 2.5rem;
            line-height: 2.5rem;
            font-size: 1rem;
            text-align: center;
            background-color: #1983d7;
        }

        .logo-section {
            padding: 0.8rem;
            margin-top: 0.3rem;
            margin-bottom: 0.3rem;
            background-color: #fff;
        }

        .logo-section img {
            width: 16.3rem;
            height: 8rem;
        }

        .main-section {
            background-color: #fff;
        }

        .news-list {
            display: flex;
            padding: 0.8rem;
            padding-bottom: 1rem;
            border-bottom: 1px solid #ddd;
        }

        .news-content {
            flex: 3;
            font-size: 0.7rem;
        }

        .news-img {
            flex: 1;
        }

        .news-img img {
            width: 4rem;
            height: 3rem;
        }

        .news-title {
            color: #333;
        }

        .news-time {
            color: #999;
            font-size: 0.6rem;
            margin-top: 0.9rem;
        }

        .news-list-template {
            display: none;
        }
    </style>
</head>
<body>
<div class="header-section">
    政策动态
</div>
<div class="logo-section">
    <img src="../assets/img/fhLogo.png" alt=""/>
</div>
<div class="main-section">
    <div class="news-list news-list-template">
        <div class="news-content">
            <div class="news-title">
                海关总署公告2017年第27号（关于实施共聚甲醛临时反倾销措施有关商品编号申报要求的公告）
            </div>
            <div class="news-time">2017-06-29</div>
        </div>
        <div class="news-img">
            <img src="../assets/img/news-default.png" alt=""/>
        </div>
        <input type="hidden"/>
    </div>
    <!-- <div class="news-list">
            <div class="news-content">
                        <div class="news-title">
                            海关总署公告2017年第25号（关于推进全国海关通关一体化改革的公告）
                        </div>
                        <div class="news-time">2017-06-28</div>
                    </div>
                    <div class="news-img">
                        <img src="../assets/img/news-default.png" alt="" />
                    </div>
    </div> -->
</div>
<script type="text/javascript" src="../assets/js/jquery.js"></script>
<script type="text/javascript" src="../assets/js/config.js"></script>
<script type="text/javascript" src="../assets/js/dropload.js"></script>
<script type="text/javascript">
    var count = 0;
    var total;
    var getSize = 10;
    function render(arg) {
        var deferred = $.Deferred();
        $.ajax({
                   /*url: '../assets/js/testData/news.js',*/
                   url: 'http://219.130.222.62:9004/yxt/a/jsonp/list.html',
                   data: {"page": arg + 1, "size": getSize},
                   type: 'get',
                   dataType: 'jsonp',
                   success: function (data) {
                       console.log(data);
                       var result = data.data.beans;
                       var len = result.length;
                       var totalLen = data.data.page.recordCount;
                       var limitLen = (totalLen - (10 * arg) >= 10) ? 10 : (totalLen - (10 * arg));
                       /*var limitLen = (3 * (1 + arg) < len) ? (3 * (1 + arg)) : len*/
                       for (var i = 0; i < limitLen; i++) {
                           $clone =
                               $(".news-list-template").clone().removeClass("news-list-template");
                           $clone.find(".news-title").text(result[i].title).next()
                               .text(result[i].publishTime).end().parents(".news-list")
                               .find(".news-img img").attr("src", result[i].firstImg).end()
                               .find("input").val(result[i].aid);
                           if (arg == 0) {
                               $(".main-section").append($clone);
                           } else {
                               $(".dropload-down").before($clone);
                           }
                       }
                       deferred.resolve(totalLen);
                   },
                   error: function (a, b, c) {
                       console.log(b);
                   }
               });
        return deferred.promise();
    }
    $(document).ready(function () {
        render(count++).then(function (arg) {
            total = arg;
            var dropload = $('.main-section').dropload({
                                                           scrollArea: window,
                                                           domDown: {
                                                               domClass: 'dropload-down',
                                                               domRefresh: '<div class="dropload-refresh">上拉加载更多</div>',
                                                               domLoad: '<div class="dropload-load"><span class="loading"></span>加载中...</div>',
                                                               domNoData: '<div class="dropload-noData">已无数据</div>'
                                                           },
                                                           loadDownFn: function (me) {
                                                               setTimeout(function () {
                                                                   if (count > Math.ceil((total
                                                                                          - getSize)
                                                                                         / getSize)) {
                                                                       me.resetload();
                                                                       me.lock();
                                                                       me.noData();
                                                                       me.resetload();
                                                                       return;
                                                                   }
                                                                   render(count++);
                                                                   me.resetload();
                                                               }, 1000)
                                                           }
                                                       });
        });

        $(".main-section").on("click", ".news-list", function () {
            var id = $(this).find("input").val();
            window.location.href = "newShow.html?id=" + id;
        })
    })
</script>
</body>
</html>
